package com.college.services;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Service;

import com.college.interfaces.IMenuNavigationConstants;
import com.college.interfaces.MenuNavigationService;

@Service
public class MenuNavigationServiceImpl implements IMenuNavigationConstants, MenuNavigationService {
	
	LinkedHashMap<String, Map> menuNavMap = new LinkedHashMap<String, Map>();
	
	LinkedHashMap<String, Map> homeMap = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> facultyMap = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> facultyChild1Map = new LinkedHashMap<String, Map>();
	
	LinkedHashMap<String, Map> studentMap = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> studentChild1Map = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> studentChild2Map = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> rolesMap = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> rolesChild1Map = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> configurationMap = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> configurationChild1Map = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> examsMap = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> examsChild1Map = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> timeTableMap = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> timeTableChild1Map = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> reportsMap = new LinkedHashMap<String, Map>();
	LinkedHashMap<String, Map> reportsChild1Map = new LinkedHashMap<String, Map>();
	public Map<String, Map> getMenuNavigationBasedOnRole(Set<GrantedAuthority> roles) {
		for(GrantedAuthority authorities:roles){
			if(authorities.equals("ROLE_USER")){
				homeMap.put(HOME_LABEL, null);

				studentChild2Map.put(STUDENT_CHILD2_ADD_ATTENDANCE, null);
				studentChild2Map.put(STUDENT_CHILD2_EDIT_ATTENDANCE, null);
				studentChild2Map.put(STUDENT_CHILD2_DELETE_ATTENDANCE, null);
				
				facultyChild1Map.put(FACULTY_CHILD1_PROFILE, null);
				facultyChild1Map.put(FACULTY_CHILD1_SETTINGS, null);
				facultyChild1Map.put(FACULTY_CHILD1_ADD_FACULTY, null);
				facultyChild1Map.put(FACULTY_CHILD1_SEARCH_FACULTY, null);
				
				studentChild1Map.put(STUDENT_CHILD1_PROFILE, null);
				studentChild1Map.put(STUDENT_CHILD1_ADD_STUDENT, null);
				studentChild1Map.put(STUDENT_CHILD1_ATTENDANCE, studentChild2Map);
				studentChild1Map.put(STUDENT_CHILD1_SESSIONALS, null);
				
				rolesChild1Map.put(ROLES_CHILD1_ASSIGN_ROLE, null);
				
				examsChild1Map.put(EXAMS_CHILD1_SHEDULE_EXAM, null);
				
				timeTableChild1Map.put(TIME_TABLE_CHILD1_ADD_TIME_TABLE, null);
				timeTableChild1Map.put(TIME_TABLE_CHILD1_EDIT_TIME_TABLE, null);
				timeTableChild1Map.put(TIME_TABLE_CHILD1_VIEW_TIME_TABLE, null);
				
				reportsChild1Map.put(REPORTS_CHILD1_ATTENDANCE_REPORT, null);
				reportsChild1Map.put(REPORTS_CHILD1_SESSIONALS_REPORT, null);
				
				configurationChild1Map.put(CONFIGURATION_CHILD1_ADD_COLLEGE, null);
				configurationChild1Map.put(CONFIGURATION_CHILD1_ADD_DEPARTMENT, null);
				configurationChild1Map.put(CONFIGURATION_CHILD1_ADD_BATCH, null);
				configurationChild1Map.put(CONFIGURATION_CHILD1_MAP_SEMESTER, null);
				configurationChild1Map.put(CONFIGURATION_CHILD1_CHANGE_PASSWORD, null);
				
				
				facultyMap.put(FACULTY_MAIN, facultyChild1Map);
				studentMap.put(STUDENT_MAIN, studentChild1Map);
				rolesMap.put(ROLES_MAIN, rolesChild1Map);
				examsMap.put(EXAMS_MAIN, examsChild1Map);
				timeTableMap.put(TIME_TABLE_MAIN, timeTableChild1Map);
				reportsMap.put(REPORTS_MAIN, reportsChild1Map);
				configurationMap.put(CONFIGURATION_MAIN, configurationChild1Map);
				
				menuNavMap.put("home",homeMap);
				menuNavMap.put("faculty",facultyMap);
				menuNavMap.put("student",studentMap);
				menuNavMap.put("roles", rolesMap);
				menuNavMap.put("exams", examsMap);
				menuNavMap.put("timetable", timeTableMap);
				menuNavMap.put("reports", reportsMap);
				menuNavMap.put("config",configurationMap);
				
			}
		}
		return menuNavMap;
	}

	
}
